{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>京东商城信得过，买的放心，用的省心、安心、放心！</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>给公司宿舍买的，上门安装很快，快递也送的及时，不错的。给五分吧</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>美的值得信赖，质量不错</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>不错不错的哦，第一次在京东买这些产品，感觉相当好</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>很满意，水方一晚上都还是热的早上还能再洗，</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                 0\n",
       "0         京东商城信得过，买的放心，用的省心、安心、放心！\n",
       "1  给公司宿舍买的，上门安装很快，快递也送的及时，不错的。给五分吧\n",
       "2                      美的值得信赖，质量不错\n",
       "3         不错不错的哦，第一次在京东买这些产品，感觉相当好\n",
       "4            很满意，水方一晚上都还是热的早上还能再洗，"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# -*- coding:utf-8 -*-\n",
    "# 原始数据去重\n",
    "import pandas as pd\n",
    "inputfile = '1_1my_meidi_jd.txt' # 评论汇总文件\n",
    "data = pd.read_csv(inputfile, encoding = 'utf-8', header = None) #(***)\n",
    "data.head()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "原始数据有55774条\n",
      "去重后数据有53049条\n"
     ]
    }
   ],
   "source": [
    "l1 = len(data) \n",
    "print u'原始数据有%d条' % l1\n",
    "data = pd.DataFrame(data[0].unique())# (*****)\n",
    "l2 = len(data)\n",
    "print u'去重后数据有%d条' % l2\n",
    "data.to_csv('2_1my_meidi_jd_delduplis.txt', header = False, index = False, encoding='utf-8') # (***)\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
